<?php
	require_once 'environment.php';
	if(!$acc->isLogged()) {
		$temp->addSubMenu("Schedule Us", "schedUs.php");
	}else if($acc->isLogged()) {
		$temp->addSubMenu("Add Event", "modEvent.php?action=addEvent");
		$temp->addSubMenu("Edit Event", "modEvent.php?action=editEvent");
		$temp->addSubMenu("Delete Event", "modEvent.php?action=delEvent");
		$temp->addSubMenu("Moderate Events", "modEvent.php?action=modEvent");
	}
	$temp->setTab(1);
	$temp->showCal();
	$temp->currentPage("Home >> Events");
	$temp->generate();
	
	$day = fixArr($_GET, "day");
	$month = fixArr($_GET, "month");
	$year = fixArr($_GET, "year");
	
	if(!$day) $day = date('j');
	if(!$month) $month = date('F');
	if(!$year) $year = date('Y');
	
	$beginning = strtotime($month." ".$day.", ".$year." 12:00 AM");
	$end = strtotime($month." ".$day.", ".$year." 11:59 PM");
	
	$sql = $db->Execute("SELECT * FROM `monster`.`event` WHERE `Date` > ? AND `Date` < ? AND `Approved` = '1' ORDER BY `event`.`Date` ASC", array($beginning, $end));
	if($sql->RecordCount() > 0) {
		print "<b>Event Details for ".ucwords($month)." {$date} {$day}".date("S", strtotime($month." ".$day.", ".$year)).", {$year}</b><br />\n";
		while($row = $sql->FetchRow()) {
			print "<br />\n"; 
			if($row['NameOfGuest'] != "") print "<b>Invited By:</b> {$row['NameOfGuest']}<br />\n";
			print "<b>Event Name:</b> {$row['Title']}<br />\n";
			print "<b>Date and Time:</b> ".date('F jS, Y g:i A', $row['Date'])."<br />\n";
			print "<b>Place:</b> {$row['Place']}<br />\n";
            print "\n<b>Description:</b><br />{$row['Description']}<br />\n";
			if($row['PhoneNumber'] != "") {
				print "<b>Phone Number:</b> {$row['PhoneNumber']}<br />\n";
			}
			if($row['Email'] != "") {
				print "<b>Email:</b> {$row['Email']}<br />\n";
			}
		}
	}else{
		if(date('j') == $day && date('F') == $month && date('Y') == $year){
			print "There are no events for today.";
		}else{
			print "There are no events for this date.";
		}
	}
?>